import { randomTxtLibrary } from '../../utils/data';
import { host } from '../global.config';
import { TestConfigEntity } from '../test.entity';
const name = `自动化测试库${randomTxtLibrary('number', 1)}`;
const identifier = randomTxtLibrary('uppercase', 4);
const members = ['aa_a1'];
export const TesthubLibrariesConfig: TestConfigEntity = {
  title: 'Testhub模块添加测试库',
  pageUrl: `${host.url}/testhub/libraries`,
  dialogTitle: '新建测试库',
  screenshotName: 'testhub_add_libraries_tests',
  operation: {
    type: 'click',
    name: 'addLibrariesBut',
    selector: 'a:has-text("新建测试库")',
  },
  from: [
    {
      type: 'fill',
      name: 'libraryName',
      selector: '.thy-input[name="libraryName"] input',
      label: '测试库名称',
      value: name,
      err_msg: ['测试库名称不能为空', '该选项输入值长度不能大于32'],
    },
    {
      type: 'fill',
      name: 'placeholder',
      selector: '.thy-input[name="styx-input-identifier"] input',
      label: '测试库标识',
      value: identifier,
      err_msg: [
        '测试库标识不能为空',
        '英文字母/数字/下划线/连接线（不超过10字符，最后一位不能为数字）',
        '测试库标识已存在',
      ],
    },
    {
      type: 'fill',
      name: 'description',
      label: '描述',
      selector: 'textarea[name="description"]',
      value: `${name}描述`,
    },
    {
      type: 'members',
      name: 'members',
      selector: '.thy-icon-user-add',
      label: '成员',
      value: members,
      list_selector: '.avatar-name',
      okBtn: 'button:has-text("确认")',
    },
    {
      type: 'click',
      name: 'okBtn',
      selector: 'button:has-text("确定")',
    },
  ],
  testPage: {
    pageUrl: `${host.url}/testhub/libraries`, // 访问项目首页看列表中是否存在创建的项目
    btnGroup: [
      {
        type: 'click',
        name: 'sortBtn',
        selector: 'a[thytooltip="排序"]',
      },
      {
        type: 'click',
        name: 'create_at',
        selector: '.action-menu-item .name:has-text("创建时间")',
      },
    ],
    table: {
      selector: 'table',
      result: [
        {label: '测试库', value: name},
        {label: '标识', value: identifier}
      ],
    },
  },
};
